package com.funsport.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.funsport.entity.EventGroupMember;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 活动分组成员Mapper接口
 *
 * @author Fun-Sport Team
 */
@Mapper
public interface EventGroupMemberMapper extends BaseMapper<EventGroupMember> {

    /**
     * 根据分组ID查询所有成员
     */
    @Select("SELECT * FROM event_group_members WHERE group_id = #{groupId}")
    List<EventGroupMember> selectByGroupId(@Param("groupId") Long groupId);

    /**
     * 根据活动ID查询所有分组成员
     */
    @Select("SELECT * FROM event_group_members WHERE event_id = #{eventId}")
    List<EventGroupMember> selectByEventId(@Param("eventId") Long eventId);

    /**
     * 查询用户在活动中的分组
     */
    @Select("SELECT * FROM event_group_members WHERE event_id = #{eventId} AND user_id = #{userId} LIMIT 1")
    EventGroupMember selectByEventIdAndUserId(@Param("eventId") Long eventId, @Param("userId") Long userId);
}

